window.name ="NG_DEFER_BOOTSTRAP!";
init =false;
var cj_shengxue_zyid;
/**
 * easyui 和 anguarjs 结合有点勉强 让它先暂停 执行等到 ajax 加载后后再进行初始化NG
 */
$('#dataGrid').datagrid({
	url : PATH+'/business/kaoshicj/list',
	fit : true,
	
	border : false,
	pagination : true,
	idField : 'ksId',
	pageSize : 10,
	pageList : [ 10, 20, 30, 40, 50 ],
	sortName : 'ksId',
	sortOrder : 'desc',
	checkOnSelect : false,
	selectOnCheck : false,
	nowrap : false,
	striped : true,
	rownumbers : true,
	singleSelect : true,
	rowStyler:function(index,row) {
		if (row.isok == '0') {
			return 'background-color:#E0ECFF;color:red;';
		}
	},
	frozenColumns : [ [ {
		field : 'ksId',
		title : '编号',
		width : 150,
		
		checkbox : true
	}, {
		field : 'name',
		title : '姓名',
		width : 65,
		sortable : true
	} ] ],
	columns : [ [ {
		field : 'zkz',
		title : '准考证',
		width : 90,
		sortable : true
	}, {
		field : 'mobile',
		title : '手机号码',
		width : 90,
		sortable : true
	},{
		field : 'pici',
		title : '批次',
		width : 50,
		sortable : true
		
	},{
		field : 'kmid',
		title : '科目',
		width : 50,
		sortable : true
		
	},{
		field : 'kmmc',
		title : '科目名称',
		width : 150,
		sortable : true
		
	},{
		field : 'cjfs',
		title : '分数',
		width : 60,
		sortable : true
		
	},{
		field : 'isSend',
		title : '发送',
		width : 60,
		sortable : true
		
	},{
		field : 'isSendReason',
		title : '原因',
		width : 120,
		sortable : true
		
	},{
		field : 'action',
		title : '操作',
		width : 100,
		formatter : formatterFun
	} ] ],
	toolbar : '#toolbar',
	onLoadSuccess : function() {
	
		$('#searchForm table').show();
		parent.$.messager.progress('close');
		$(this).datagrid('tooltip');
	
		if(!init){
		
			angular.resumeBootstrap();
			init=true;
		}
		
		
		
	},
	onRowContextMenu : function(e, rowIndex, rowData) {
		e.preventDefault();
		$(this).datagrid('unselectAll');
		$(this).datagrid('selectRow', rowIndex);
		$('#menu').menu('show', {
			left : e.pageX,
			top : e.pageY
		});
	}
});
MainApp.controller('KaoshicjCtrls', [ '$scope', function($scope) {
$scope.load=function(){
	$scope.createNote();
};

$scope.createNote=function(){
	$("#cj_kmid").combogrid({
		striped : true,
		rownumbers : true,
		   panelWidth:550,
		   idField:"kmid",
		   textField:"kmmc",
		   sortName : 'kmlx',
			sortOrder : 'desc',
			pagination : true,
			pageSize : 10,
		   url:PATH+'/business/zykm/selectKemuByZyid',
		   columns:[[ 
		         {field:'kmid',title:'代码',width:100}, 
		         {field:'kmmc',title:'名称',width:100},
		         {field:'kmlxMc',title:'类型',width:80},
		         {field:'kmxf',title:'学分',width:50}
		      ]]
		  });
	$("#xuesheng_cjcombobox_edit").combogrid({
		striped : true,
		rownumbers : true,
		   panelWidth:550,
		   idField:"id",
		   textField:"name",
		   sortName : 'id',
			sortOrder : 'desc',
			pagination : true,
			pageSize : 10,
		
		   url:PATH+'/business/xuesheng/list',
		   keyHandler : {
				enter : function() {
					$("#xuesheng_cjcombobox_edit").combogrid({
						queryParams : {
							
							'name' : $("#xuesheng_cjcombobox_edit").combogrid('getText')

						}
					});
				}
			},
		   columns:[[ 
		         {field:'name',title:'姓名',width:100}, 
		         {field:'zkz',title:'准考证',width:100},
		         {field:'zhuanyemc',title:'专业',width:250},
		         {field:'mobile',title:'手机号码',width:100}
		       
		      ]],
				onSelect : function(index,record) { //选中处理
					
					
					cj_shengxue_zyid=record.zyId;
					$("#cj_kmid").combogrid(
							{
								queryParams : {
									 'zyid':cj_shengxue_zyid
								}
							});
					}
		  });
};






$scope.deleteFun=function(id) {
	if (id == undefined) {
		var rows = $('#dataGrid').datagrid('getSelections');
		id = rows[0].ksId;
	}
	parent.$.messager.confirm('询问', '您是否要删除当前记录？', function(b) {
		if (b) {
			parent.$.messager.progress({
				title : '提示',
				text : '数据处理中，请稍后....'
			});
			$.post(PATH+'/business/kaoshicj/delete', {
				id : id
			}, function(result) {
				if (result.success) {
					$('#dataGrid').datagrid('reload');
				}
				parent.$.messager.progress('close');
			}, 'JSON');
		}
	});
};
$scope.editFun=function(id) {

	if (id != undefined)$('#dataGrid').datagrid('selectRecord', id);
	
	var node = $('#dataGrid').datagrid('getSelected');
	if (node) {
		loadFrom('#fm_cj',node);
		$('#zyidcombobox_edit').combogrid('setValue', node.zyId);
		showDialog('#dlg','编辑信息');
		url=PATH+'/business/kaoshicj/edit';
	}
};

$scope.addFun=function() {
	  $('#fm_cj').form('clear');
	
	  showDialog('#dlg','添加信息');
	  url=PATH+"/business/kaoshicj/add";
	  
};
$scope.exportFun=function() {
			window.location.href=PATH+"/business/kaoshicj/export";
};

$scope.getCjFun=function() {
	
	showDialog('#dlg3','获取座位');
};
$scope.sendCjFun=function() {
	
	showDialog('#dlg4','发送成绩');
};
$scope.submitGetCj=function() {
	parent.$.messager.progress({
		title : '提示',
		text : '数据处理中，请稍后....'
	});
$('#fm3').form('submit',{
    url: PATH+'/business/kaoshicj/getcj',
    success: function(result){
     result= $.parseJSON(result);
	 $('#dlg3').dialog('close');
 	parent.$.messager.progress('close');
     if(result.success==true){
    	 $('#dataGrid').datagrid('reload');
    	  $.messager.alert('提示',"操作成功");
      }
    else {
    	$.messager.alert('提示',result.data);
    }
 }
});};
$scope.submitSendCj=function() {
	parent.$.messager.progress({
		title : '提示',
		text : '数据处理中，请稍后....'
	});
$('#fm4').form('submit',{
    url: PATH+'/business/sms/cj',
    success: function(result){
     result= $.parseJSON(result);
	 $('#dlg4').dialog('close');
 	parent.$.messager.progress('close');
     if(result.success==true){
    	 $('#dataGrid').datagrid('reload');
    	 if(result.data){
    		 $.messager.alert('提示',"操作成功,"+result.data);
    	 }else{
    		 $.messager.alert('提示',"操作成功");
    	 }
    	  
      }
    else {
    	$.messager.alert('提示',result.data);
    }
 }
});};
$scope.submit=function(){
     $('#fm_cj').form('submit',{
                url: url,
                success: function(result){
                 result= $.parseJSON(result);
                 if(result.success){
                  $('#dlg').dialog('close'); 
                  $('#dataGrid').datagrid('reload');
                  }
                else {
                  $.messager.alert('提示',result.data);
                }
             }
       });		
};

$scope.searchFun=function() {
	$('#dataGrid').datagrid('load', $.serializeObject($('#searchForm')));
};
$scope.cleanFun=function() {
	$('#searchForm input').val('');
	$('#dataGrid').datagrid('load', {});
};
$scope.batchDeleteFun=function() {
	var dg=$('#dataGrid');
	var rows = dg.datagrid('getChecked');
	var ids = [];
	if (rows.length > 0) {
		parent.$.messager.confirm('确认', '您是否要删除当前选中的项目？', function(r) {
			if (r) {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				for ( var i = 0; i < rows.length; i++) {
					
						ids.push(rows[i].ksId);
					
				}
				$.getJSON(PATH+'/business/kaoshicj/batchDelete', {
					ids : ids.join(',')
				}, function(result) {
					parent.$.messager.progress('close');
					if (result.success) {
						dg.datagrid('load');
						
					}else{
						parent.$.messager.alert('提示', result.data, 'info');
					}
					
						
					
					
				});
			}
		});
	} else {
		parent.$.messager.show({
			title : '提示',
			msg : '请勾选要删除的记录！'
		});
	}
}
 


} ]);












 

